package com.jvm;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: demo
 * @description:
 * @author: zxb
 * @date: 2021-01-22 23:06
 **/
public class OOMObject {
    public byte[] bytes = new byte[128 * 1204];
    public static void main(String[] args) throws InterruptedException {
        // 睡五秒，用来启动Jconsole
        Thread.sleep(5000);
        System.out.println("start...");
        fillHeep(1000);
    }

    private static void fillHeep(int i) throws InterruptedException {
        List<OOMObject> objects = new ArrayList<OOMObject>();
        for (int j = 0; j < i; j++) {
            Thread.sleep(500);
            objects.add(new OOMObject());
        }

    }
}
